<template>
    <c-list-template title="发货申请管理" :operation="true">
        <template slot="search">
            <el-row :gutter="5">
                <el-col :span="6" class="flex-center">
                    <div class="mr-lg">供应商名称</div>
                    <el-input v-model="querys.sellerName" placeholder="请输入供应商名称" class="wh flex-1 mr-lg" />
                </el-col>
                <el-col :span="6" class="flex-center">
                    <div class="mr-lg">车辆信息：</div>
                    <el-input v-model="querys.carInfo" placeholder="请输入车辆信息" class="wh flex-1 mr-lg" />
                </el-col>
                <el-col :span="6" class="flex-center ">
                    <div class="mr-lg">订单号：</div>
                    <el-input v-model="querys.orderId" placeholder="请输入订单号" class=" wh flex-1 mr-lg" />
                </el-col>

                <el-col :span="6" class="flex-x-end ">
                    <el-button icon="el-icon-search" type="primary" @click="handleSelect">搜索</el-button>
                    <el-button icon="el-icon-delete" @click="handleReset">重置</el-button>
                </el-col>
            </el-row>
        </template>
        <template slot="list">
            <el-table :header-cell-style="{ background: '#F1F1F1', color: '#092132' }" :data="tableData" v-loading="loading">
                <el-table-column label="序号" align="center" width="80" type="index" />
                <el-table-column label="发货单号" width="200" align="center" prop="id" />
                <el-table-column label="车辆信息" width="200" align="center" prop="productInfo" />
                <el-table-column label="发货数量（台）" width="150" align="center" prop="productAmount" />
                <el-table-column label="起运港" width="150" align="center" prop="startHarborName" />
                <el-table-column label="目的地" width="150" align="center" prop="endHarborName" />
                <el-table-column label="供应商名称" width="200" align="center" prop="sellerName" />
                <el-table-column label="订单号" width="200" align="center" prop="orderId" />
                <el-table-column label="状态" width="150" align="center">
                    <template slot-scope="scope">
                        {{scope.row.status == null ? "" : shipmentStatus[scope.row.status].label}}
                    </template>
                </el-table-column>

                <el-table-column fixed="right" label="操作" align="center">
                    <template slot-scope="scope">
                        <el-link type="primary" v-if="scope.row.status == 0" @click="handleDetails(scope.row,false)">审核</el-link>
                        <el-link type="primary" v-else @click="handleDetails(scope.row,true)">详情</el-link>
                    </template>
                </el-table-column>
            </el-table>
        </template>
        <template slot="pagination">
            <el-pagination background :current-page="querys.current" :page-sizes="[10, 20, 50, 100]" :page-size="querys.size" layout="total, sizes, prev, pager, next, jumper" :total="total" @size-change="handleSizeChange" @current-change="handleCurrentChange" />
        </template>
    </c-list-template>
</template>
<script>
import { shipmentStatus } from "@/utils/status.js";
export default {
    data () {
        return {
            total: 0,
            tableData: [],
            querys: {
                current: 1,
                size: 10,
                startTime: "",
                endTime: ""
            },
            timeExpiry: "",
            loading: false,
            shipmentStatus: shipmentStatus
        };
    },
    mounted () {
        this.tableList();
    },
    methods: {
        dataChange () {
            this.querys.startTime = this.timeExpiry[0]
            this.querys.endTime = this.timeExpiry[1]
        },

        handleDetails (item, isView) {
            this.$router.push({
                path: "/tradeOrder/shipmentApply/details",
                query: {
                    id: item.id,
                    isView: isView
                },
            });
        },
        tableList () {
            this.loading = true;
            const params = JSON.parse(JSON.stringify(this.querys));
            const url = "/sellerDeliveryList/page";
            this.$get({ url, params }).then((res) => {
                this.tableData = res.records;
                this.total = res.total * 1;
                this.loading = false;
            });
        },
        handleReset () {
            this.querys = {
                current: 1,
                size: 10,
            };
            this.tableList();
        },
        handleSelect () {
            this.querys.current = 1;
            this.tableList();
        },
        handleSizeChange (val) {
            this.querys.size = val;
            this.tableList();
        },
        handleCurrentChange (val) {
            this.querys.current = val;
            this.tableList();
        },
    },
};
</script>
